package java_DesignPattern.BehavioralPattern.VisitorPattern;

import java.util.ArrayList;
import java.util.List;

/**
 * 家庭类---对象结构类
 */
public class Home{

    private List<Animal> animals = new ArrayList<>();

    //添加具体元素
    public void addAnimal(Animal animal) {
        animals.add(animal);
    }

    // 访问者访问
    public void action(Person visitor) {
        for (Animal animal : animals) {
            animal.accept(visitor);
        }
    }
}
